package com.lagou.dao;

import com.lagou.entity.Orders;
import com.lagou.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class OrdersDao{
    public List<Orders> findAllOrders(String uid) throws SQLException {
        QueryRunner qr = new QueryRunner(DruidUtils.dataSource);

        String sql = "select * from orders where uid = ?";

        List<Orders> orders = qr.query(sql, new BeanListHandler<Orders>(Orders.class), uid);
        return orders;
    }
}
